package com.yixiang.np.utils;

import com.alibaba.fastjson.JSONObject;
import com.yixiang.np.constant.GlobalConstant;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * Created by pengpeng on 16-10-18.
 */
public class CheckResp {

    public static Boolean checkPssPostResp(ResponseEntity<String> pssResp) {
        boolean flag = false;
        if (pssResp != null && pssResp.getStatusCode() != null) {//判断http响应
            HttpStatus httpStatus = pssResp.getStatusCode();
            if (httpStatus != null && httpStatus.equals(HttpStatus.OK)) {
                JSONObject pssJson = JSONObject.parseObject(pssResp.getBody());
                if (pssJson != null) {
                    if (pssJson.get("status") != null && pssJson.get("status").toString().equals(GlobalConstant.PSS_ORDER_CREATE_OK)) {
                        flag = true;
                    }
                }
            }
        }
        return flag;
    }

    public static Boolean checkHttpResp(ResponseEntity<?> pssResp) {
        boolean flag = false;
        if (pssResp != null && pssResp.getStatusCode() != null) {//判断http响应
            HttpStatus httpStatus = pssResp.getStatusCode();
            if (httpStatus != null && httpStatus.equals(HttpStatus.OK)) {
                flag = true;
            }
        }
        return flag;
    }


}
